<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ page import="java.sql.*"%>
<title>登录检查</title>
</head>
<body>
<%
	String stuId= request.getParameter("stuId");
	String stuPwd = request.getParameter("stuPwd");
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/classfee", "root", "1234");
	Statement stmt = con.createStatement();
	  ResultSet rst=stmt.executeQuery("select *from tb_student where stuId='"+stuId+"' and stuPwd='"+stuPwd+"'");
	  if(rst.next())
	  {
		if( stuPwd.equals(rst.getString("stuPwd")))
     	{
     		session.setAttribute("stuId",stuId);
             //关闭连接、释放资源
             rst.close();
             stmt.close();
             con.close();  
             out.println(stuId);
     		response.sendRedirect("tb_student/studentInfo.jsp");
     	}
	  }
	  else
     {
		  out.println("<script>alert('密码错误或者用户名不存在,请重新登录!');window.location='stuLogin.html'</script>");
 		  return ;
     }
     rst.close();
     stmt.close();
     con.close();
%>
</body>
</html>